package com.cysyz.mylib.domain;

import javax.persistence.Transient;

/**
 * Created by cuiyong on 15/2/1.
 */
public class MyTableEntity implements MyTablePagable
{
    @Transient
    private int page;
    @Transient
    private int maxResult;

    @Override
    public void setStart(int start) {
        if (maxResult <= 0) {
            throw new ExceptionInInitializerError("想要设置start，需要首先设置length");
        }
        page = start/maxResult+1;
    }

    @Override
    public void setLength(int length) {
        this.maxResult = length;
    }

    @Override
    public void setPage(int page) {
        this.page = page;
    }

    @Override
    public int getPage() {
        return this.page;
    }

    @Override
    public void setMaxResult(int maxResult) {
        this.maxResult = maxResult;
    }

    @Override
    public int getMaxResult() {
        return this.maxResult;
    }
}
